package com.amado.course36ByteStream;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class S06CopyFile {
	public static void main(String[] args) {
		// 输入流，读取文件内容
		FileInputStream in = null;
		FileOutputStream out = null;
		try {
			in = new FileInputStream("d:/aaa.txt");
			// 输出流，写入文件内容
			out = new FileOutputStream("d:/bbb.txt");
			byte[] datas = new byte[1024];
			// 读取到byte数组
			int i = in.read(datas);
			while (i != -1) {
//			out.write(datas);
				// 写入byte数组
				out.write(datas, 0, i);
				i = in.read(datas);
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			// 关闭流
			try {
				in.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			try {
				out.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

}
